﻿//需求、借款、报销流程
function audaction()
{
    $("#ApprovalControl_panelApproval_txtMemo_I").val($("#txtsubject").val());
    $("#TransmitId").val($("#hdzuser").val());
    $("#txtTransmitId").val($("#txtzuser").val());
    jq("#jQUi").actionsheet(
                    [{
                        text: '批准',
                        cssClasses: 'red',
                        handler: function ()
                        {
                            jq.ui.showMask("处理中....");
                            document.getElementById("btnSubmit").click();
                        }
                    },
                    {
                        text: '退回',
                        cssClasses: 'blue',
                        handler: function ()
                        {
                            jq.ui.showMask("处理中....");
                            //提交审批意见
                            document.getElementById("btnReturn").click();
                        }

                    }, {
                        text: '取消',
                        cssClasses: '',
                        handler: function () { }
                    }]
                );
}
function SDetp()
{
    var dept = $("#SelectForDept").val();
    var name = $("#selectname").val();
    jq.post("../../mobi/Proc/GetData.ashx", { TYPE: "GetUser", PARA: dept + "," + name }, function (data)
    {
        jq("#testform").html(CreateHtml(data));
    });
}

function CreateHtml(ud)
{
    var obj = $.parseJSON(ud);
    var str = "";
    for (var i = 0, len = obj.length; i < len; i++)
    {
        str += "<fieldset><input type='checkbox' EmpCode=" + obj[i].EmpCode + " EmpName=" + obj[i].Name + " name='dns_area'  value='" + obj[i].LoginName + "' /> " + obj[i].EmpCode + "--" + obj[i].Name + "--" + obj[i].DeptName + " </fieldset>";
    }
    return str;
}
function btnconfirm()
{
    $("input[name='dns_area']:checkbox").each(function ()
    {
        var ck = $(this).attr("checked");
        if (ck)
        {
            var EmpCode = $(this).attr("EmpCode");
            var EmpName = $(this).attr("EmpName");
            var value = $(this).val();
            txtzuser.value += EmpName + ",";
            hdzuser.value += value + ",";
        }
    });
    jq.ui.loadContent('nowaud', false, false, 'pop');
}


function setmainhtml()
{
    var str = "";
    $("#NeedsOfBorrower_panelNeedsOfBorrower_RPC").find(".cell").each(function (i)
    {
        if (i == 1 || i == 15 || i == 17 || i == 19 || i == 21 || i == 23)
        {
            if (i == 23)
            {
                str += "<br><textarea class='jq-ui-forms'  readonly='readonly'> " + $.trim($(this).find("textarea")[0].value) + "</textarea><br>";
            }
            else
            {
                if ($(this).find("input")[0] != null)
                {
                    str += "<br><input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $.trim($(this).find("input")[0].value) + "'><br>";
                }
                else
                {
                    str += "<br>";
                }
            }
        }
        else if (i == 3 || i == 5 || i == 7 || i == 9 || i == 11 || i == 13)
        {
            str += "<br><input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $.trim($(this).text()) + "'><br>";
        }
        else
        {
            str += $(this).text();
        }
    });
    $("#main").html("<fieldset>" + str + "</fieldset>");
}
function setshenpihtml()
{
    var htitle = new Array();
    var bconte = "";
    $(".TableHeader").find("th").each(function (i) { htitle.push($(this).text()) });
    $(".TableData1").each(function (i)
    {
        bconte += "<fieldset><legend>";
        $(this).find("td").each(function (j)
        {
            if (j == 0)
            {
                bconte += htitle[j] + ":" + $.trim($(this).text()) + " </legend>";
            }
            else if (j == 1)
            {
                bconte += $.trim($(this).text()) + "、";
            }
            else if (j == 2)
            {
                bconte += $.trim($(this).text())+ "<br>";
            }
            else if (j == 3)
            {
                bconte += htitle[j] + "<br><textarea class='jq-ui-forms' style='min-height:80px;' type='text' readonly='readonly' >" + $.trim($(this).text()) + "</textarea>";
            }
            else
            {
                bconte += htitle[j] + "<input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $.trim($(this).text()) + "'><br>";
            }
        });
        bconte += "</fieldset>";

    });
    $("#hisaud").html(bconte);
}

//MobiMaterialsProcurementApproval可用，
function SetCaigoumingxi()
{
    var jkfs = "",jkje = "",mxconte="";
    var mxtitle = new Array();
    if (document.getElementById("MaterialsProcurementInfo_panelProcurementLoanBasis_cmbProcurementLoanBasis_I") != null)
    {
        jkfs=$("#MaterialsProcurementInfo_panelProcurementLoanBasis_cmbProcurementLoanBasis_I").val();
    }
    if (document.getElementById("txtProcurementLoanAmount_I") != null)
    {
        jkje = $("#txtProcurementLoanAmount_I").val();
        mxconte = "<fieldset><legend>采购信息</legend>采购借款方式：" + jkfs + "<br> 采购借款金额：" + jkje + " </fieldset>";
    }
    
    $("#MaterialsProcurementDetail_panelMaterialsProcurement_gridMaterialsProcurement_DXMainTable .dxgvHeader").each(function (i) { mxtitle.push($(this).text()) });
    $("#MaterialsProcurementDetail_panelMaterialsProcurement_gridMaterialsProcurement_DXMainTable .dxgvDataRow").each(function (i)
    {
        mxconte += "<fieldset><legend>采购明细" + parseInt(i + 1) + "</legend>";
        $(this).find("td").each(function (j)
        {
            mxconte += mxtitle[j] + "<br><input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $.trim($(this).text()) + "'/><br>";

        });
        mxconte += "</fieldset>";
    });
    $("#caigouDetails").html(mxconte);
}

//报销相关
function SetBaoxiaomingxi()
{
    var fybxlx = "", fybxzje = "", fybxfs = "", mxconte = "";
    var mxtitle = new Array();
    if (document.getElementById("ReimbursementExpensesInfo_panelReimbursementExpenses_cmbReimbursementType_I") != null)
    {
        fybxlx = $("#ReimbursementExpensesInfo_panelReimbursementExpenses_cmbReimbursementType_I").val();
    }
    if (document.getElementById("ReimbursementExpensesInfo_panelReimbursementExpenses_txtReimbursementTotalAmount_I") != null)
    {
        fybxzje = $("#ReimbursementExpensesInfo_panelReimbursementExpenses_txtReimbursementTotalAmount_I").val();
    }
    if (document.getElementById("ReimbursementExpensesInfo_panelReimbursementExpenses_cmbReimbursementMode_I") != null)
    {
        fybxfs = $("#ReimbursementExpensesInfo_panelReimbursementExpenses_cmbReimbursementMode_I").val();
        mxconte = "<fieldset><legend>报销信息</legend>费用报销类型：" + fybxlx + "<br> 费用报销总金额：" + fybxzje + "<br> 费用报销方式：" + fybxfs + "  </fieldset>";
    }

    $("#ReimbursementExpensesDetail_panelReimbursementExpenses_gridReimbursementExpenses_DXMainTable .dxgvHeader").each(function (i) { mxtitle.push($(this).text()) });
    $("#ReimbursementExpensesDetail_panelReimbursementExpenses_gridReimbursementExpenses_DXMainTable .dxgvDataRow").each(function (i)
    {
        mxconte += "<fieldset><legend>报销明细" + parseInt(i + 1) + "</legend>";
        $(this).find("td").each(function (j)
        {
            mxconte += mxtitle[j] + "<br><input class='jq-ui-forms'  type='text' readonly='readonly' value='" + $.trim($(this).text()) + "'/><br>";
        });
        mxconte += "</fieldset>";
    });
    $("#baoxiaoDetails").html(mxconte);

}
function custom_close(msg)
{
    jq.ui.hideMask();
    jq("#jQUi").popup({ title: "提示",
        message: msg,
        cancelText: "不关闭",
        cancelCallback: function () { },
        doneText: "关闭当前页",
        doneCallback: function ()
        {
            if (navigator.appName == "Netscape")
            {
                window.open('', '_self', '');
                window.close();
            }
            else
            {
                if (navigator.appName == "Microsoft Internet Explorer")
                {
                    window.opener = "whocares";
                    window.opener = null;
                    window.open('', '_top');
                    window.close();
                }
            }
        },
        cancelOnly: false
    }
                );
}
